<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
</head>
<body>
    <div>div</div>
    <p>p</p>
    <div>div</div>
    <span>span</span>
    <p>p</p>
    <div>div</div>
</body>
<script>
    // 遍历数组
    function each ( arr, callback ) {
        for ( var i = 0; i < arr.length; i++ ) {
            callback( arr[ i ], i );
        }
    }
    // 实现链式编程
    function select( selector ) {
        var obj = document.querySelectorAll( selector );
        obj.each = function ( callback ) {
            each( this, callback );
        };
        return obj;
    }

    select( 'div, p').each( function ( v ) {
        v.style.border = '1px solid blue';
    });
</script>
</html>